import { Menu } from '../src/api/menu/type'
function createAdminMenuList(): Menu[] {
  return [
    {
      name: '首页',
      path: '/',
      icon: 'HomeFilled',
    },
    {
      name: '数据大屏',
      path: '/screen',
      icon: 'DataLine',
    },
    {
      name: '权限管理',
      path: '/role',
      icon: 'Star',
      children: [
        {
          name: '用户管理',
          path: '/acl/user',
          icon: 'User',
        },
        {
          name: '角色管理',
          path: '/acl/role',
          icon: 'Management',
        },
        {
          name: '菜单管理',
          path: '/acl/permission',
          icon: 'menu',
        },
      ],
    },
    {
      name: '商品管理',
      path: '/product',
      icon: 'GoodsFilled',
      children: [
        {
          name: '商品属性',
          path: '/product/attribute',
          icon: 'MagicStick',
        },
        {
          name: '商品品牌',
          path: '/product/brand',
          icon: 'Handbag',
        },
        {
          name: 'SKU',
          path: '/product/SKU',
          icon: 'Magnet',
        },
        {
          name: 'SPU',
          path: '/product/SPU',
          icon: 'Help',
        },
      ],
    },
  ]
}

function createSystemMenuList() {
  return [{}]
}

export default [
  {
    url: '/api/user/menu',
    method: 'get',
    response: (request) => {
      //获取请求头携带token
      const token = request.headers.token
      if (token === 'Admin Token') {
        const result = createAdminMenuList()
        result.forEach((menu, index) => {
          menu.index = index
        })
        return result
      }
      if (token === 'System Token') {
        const result = createSystemMenuList()
        return result
      }
      return []
    },
  },
]
